package com.witmore.neutron.ai.web.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.event.EventListener;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * @author 豆子高
 * @date 2025-05-26 10:22
 */
@Slf4j
@Component
public class StartupListener {

    @Autowired
    private ApplicationContext appContext;
    @EventListener(ApplicationReadyEvent.class)
    public void onApplicationReady() {
        Environment environment = appContext.getEnvironment();
        String port  = environment.getProperty("server.port");
        String contextPath = environment.getProperty("server.servlet.context-path", "/dashboard");
        log.info("\n=========================================\n" +
        "控制台页面访问地址: http://localhost:{}{}\n" +
                "=========================================\n", port, contextPath);
    }
}
